from django.db import models

# Create your models here.
from django.db.models import PROTECT,DO_NOTHING


class MS_COLLEGE(models.Model):
    ID =models.AutoField(primary_key=True)
    SchoolName = models.CharField(max_length=30,blank=False)
    USERNAME = models.CharField(max_length=20, blank=False, default=None, unique=True, null=False)
    PASSWORD = models.CharField(max_length=20,null=False, blank=False)
    hasTimes = models.IntegerField(null=False,default=0,blank=False)
    UPDATED_TIME = models.DateTimeField(auto_now_add=True)
    def __str__(self):
        return f"{self.SchoolName},调用次数还剩余:{self.hasTimes} 次"
    class Meta:
        verbose_name = '图书--学院表'
        verbose_name_plural = verbose_name

class MS_BookLibrary(models.Model):
    BOOK_School = models.ManyToManyField('MS_COLLEGE',related_name='book_college',blank=False)
    series =models.CharField(max_length=2000,blank=True,default='0',null=False)
    pagesize =models.CharField(max_length=2000,blank=True,default='0',null=False)
    authorintro =models.CharField(max_length=2000,blank=True,default='0',null=False)
    edition =models.CharField(max_length=2000,blank=True,default='0',null=False)
    yinci =models.CharField(max_length=100,blank=True,default='0',null=False)
    paper =models.CharField(max_length=100,blank=True,default='0',null=False)
    subject =models.CharField(max_length=2000,blank=True,default='0',null=False)
    wordnum =models.CharField(max_length=2000,blank=True,default='0',null=False)
    img =models.CharField(max_length=200,blank=True,default='0',null=False)
    bookcatalog =models.CharField(max_length=2000,blank=True,default='0',null=False)
    gist =models.CharField(max_length=3000,blank=True,default='0',null=False)
    publisher =models.CharField(max_length=2000,blank=False,default='0',null=False)  ##出版单位 publisher  5
    annotation =models.CharField(max_length=2000,blank=True,default='0',null=False)
    author =models.CharField(max_length=2000,blank=False,default='0',null=False)  #作者（著者）4
    title =models.CharField(max_length=2000,blank=False,default='0',null=False)  #excel 书名 书刊名 图书分类（分类号）2
    isbn10 =models.CharField(max_length=2000,blank=True,default='0',null=False)
    page =models.CharField(max_length=200,blank=True,default='0',null=False)
    page_format =models.CharField(max_length=2000,blank=True,default='0',null=False)
    isbn =models.CharField(max_length=100,blank=False,default='',null=False,unique=True)  #execl 书号（ISBN）1
    publisher_pubdate =models.CharField(max_length=2000,blank=True,default='0',null=False)
    title_author =models.CharField(max_length=2000,blank=True,default='0',null=False)
    pubdate =models.CharField(max_length=100,blank=True,default='0',null=False)  #出版日期  6
    keyword =models.CharField(max_length=3000,blank=True,default='0',null=False)
    levelnum =models.CharField(max_length=100,blank=True,default='0',null=False)
    genus =models.CharField(max_length=2000,blank=True,default='0',null=False)  #中图书分类（分类号）3
    format =models.CharField(max_length=2000,blank=True,default='0',null=False)
    heatnum =models.CharField(max_length=2000,blank=True,default='0',null=False)
    price =models.CharField(max_length=100,blank=True,default='0',null=False)   #定价，单价 7
    batch =models.CharField(max_length=2000,blank=True,default='0',null=False)
    pubplace =models.CharField(max_length=2000,blank=True,default='0',null=False)
    binding =models.CharField(max_length=2000,blank=True,default='0',null=False)
    language =models.CharField(max_length=2000,blank=True,default='0',null=False)
    ciptxt =models.CharField(max_length=3000,blank=True,default='0',null=False)
    produce =models.CharField(max_length=2000,blank=True,default='0',null=False)
    def __str__(self):
        return f"{self.title},主编{self.author} 次, 书号：{self.isbn}"
    class Meta:
        verbose_name = '图书--书号合集'
        verbose_name_plural = verbose_name

